package com.alfayun.fiscalriskanalysis.report;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alfayun.fiscalriskanalysis.enterprise.Enterprise;
import com.alfayun.fiscalriskanalysis.reportspec.ReportType;

@Controller
@RequestMapping("/client/reportGroup")
public class ReportGroupController {
    
    @Autowired
    private ReportGroupService reportGroupService;
    
    @PostMapping("/add/{reportType}")
    @ResponseBody
    public String add(Model model, ReportGroup reportGroup, @PathVariable ReportType reportType) {
        ReportGroup savedReportGroup = reportGroupService.add(reportGroup, reportType);
        /*
         * if(savedReportGroup!=null) { model.addAttribute("reportGroup", savedReportGroup);
         * 
         * List<Report> list = reportRepository.findByReportGroupId(savedReportGroup.getId());
         * model.addAttribute("reportList", list);
         * 
         * }
         */
        //return "/client/financial/list";
        if(savedReportGroup!=null) {
            return savedReportGroup.getId().toString();
        }
        return null;
    }

   
}
